import { createRouter,createWebHistory,createWebHashHistory } from 'vue-router'
import Chat from "@/pages/chat/Chat.vue";
import Index from "@/pages/layout/index.vue";
import Knowledge from "@/pages/knowledge/knowledge.vue";
import Retrieval from "@/pages/retrieval/index.vue";
import Settings from "@/pages/settings/index.vue";
import Login from  "@/pages/login/login.vue"
import Register from  "@/pages/login/register.vue"

const routes = [
    {
        name: "home",
        path: "/",
        component: Index,
        redirect: "/knowledge",
    },
    {
        name: "index",
        path: "/index",
        component: () => import("@/pages/layout/index.vue"),
        
        children: [
            {
                name: "knowledge",
                path: "/knowledge",
                component: Knowledge,
            },
            {
                name: "list",
                path: "/knowledge/list",
                component: () => import("@/pages/knowledge/list.vue")
            },
            {
                name: "chat",
                path: "/chat",
                component: Chat
            },
            {
                name: "retrieval",
                path: "/retrieval",
                component: Retrieval
            },
            {
                name: "settings",
                path: "/settings",
                component: Settings,
                redirect: "/settings/info",
                children: [{
                    name: "info",
                    path: "/settings/info",
                    component: () => import("@/pages/settings/info.vue")
                },{
                    name: "changePwd",
                    path: "/settings/changePwd",
                    component:  () => import("@/pages/settings/change_pwd.vue")
                },{
                    name: "model",
                    path: "/settings/model",
                    component:  () => import("@/pages/settings/model.vue")
                }]
            }
        ]
    },
    {
        name: "login",
        path: "/login",
        component: Login
    },
    {
        name: "register",
        path: "/register",
        component: Register
    },
    {
        path: '/404',
        name: 'NotFound',
        meta: {
          title: 'Page not found',
          isLogin: false
        },
        component: () => import('@/pages/error/404.vue')
      },
      // 所有未定义路由，全部重定向到404页
      {
        path: "/:pathMatch(.*)*",
        redirect: '/404'
      }
    
]

const router = createRouter({
    history: createWebHistory(),
    // history:createWebHashHistory(),
    routes,
})

export default router;